<?php

class Application_Form_Advertisers extends Zend_Form
{
    public function __construct()
    {
        ///$translate = new My_Action_Helper_Lang();

        $this->setName('advertisers');
        parent::__construct();

        $login = new Zend_Form_Element_Text('username');
        $login->setLabel('Username')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('Db_NoRecordExists', false, array(
                    'table' => 'advertisers',
                    'field' => 'login'))                
                ->addFilter('StringTrim')
                ->addFilter('StripTags');

        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Password')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('StringLength', true, array(8,20))
                ->addValidator('Alnum')
                ->addFilter('StringTrim')
                ->addFilter('StripTags');

        $repeat_password = new Zend_Form_Element_Password('repeat_password');
        $repeat_password->setLabel('Repeat password')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('Alnum')                                
                ->addFilter('StringTrim')
                ->addFilter('StripTags');

        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email address')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('EmailAddress')                
                ->addFilter('StringTrim')
                ->addFilter('StripTags');

        $phone = new Zend_Form_Element_Text('phone');
        $phone->setLabel('Phone')
                ->addValidator('Digits')
                ->addFilter('StringTrim')
                ->addFilter('StripTags');

        $company = new Zend_Form_Element_Text('company');
        $company->setLabel('Company name')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('Alnum', false, array('allowWhiteSpace' => true))
                ->addFilter('StringTrim')
                ->addFilter('StripTags'); 
        
        $address = new Zend_Form_Element_Text('address');
        $address->setLabel('Address')
                ->addFilter('StringTrim')
                ->addFilter('StripTags');

        $site = new Zend_Form_Element_Text('site');
        $site->setLabel('Website')
                ->addFilter('StringTrim')
                ->addFilter('StripTags');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Registration')
               ->setAttrib('class', 'button');

        $this->addElements(array($login, $password, $repeat_password, $email, 
            $phone, $address, $company, $site, $submit));
    }
}

